// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   ProviderImportFormDao.java

package fy.uap.imp;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.seeyon.ctp.util.UUIDLong;

import fy.config.FyConfig;
import fy.uap.bean.ProviderImportFormBean;
import fy.uap.bean.RangeBean;
import fy.util.DBUtil;
import fy.util.MyUtil;

// Referenced classes of package com.seeyon.v3x.plugin.oa2other.uap.dao:
//            SupplyTypeBean

public class ProviderImportFormDao3 {

	private static final String UPDATE_VENDOR_INVCLASS_STATE_CHANGE = "update fy_supplier_vendor_invclass set cvendorclass=?, changeTrace=?, denddate=?,bankaccountname=?,bankcode = ?, bank = ?,bankaccount = ?,currency = ? where pk_veninv=? and cvendorclass<>'3'";
	private static Log log = LogFactory.getLog(ProviderImportFormDao3.class);
	private static final String updateSuppliserBankInfo = "update fy_supplier_vendor_invclass i set i.bankaccountname=?,i.bankcode = ?, i.bank = ?,i.bankaccount = ?,i.currency = ? where i.pk_vendor = ( select v.pk_vendor from fy_supplier_vendor v where v.cvencode = ? and nvl(v.dr,0) = 0) and i.pk_corp=?";
	private static final String insertSuppliserVendor = "insert into fy_supplier_vendor (pk_vendor,cvencode,cvenname,ctrade,cvenregcode,dorf,cqualitycond,cvenbank,cvenaccount,cmoneytype,cpurbillcode,couttype,cvenaddress,cvenpostcode, cvenperson, cvenphone,cvenfax,cvenemail,cveniaddress,ccuspaycond,ccontent,cycle,ccreateperson,dvendevdate, ts, creater,cVenBankMemo,cvenfygl ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	private static final String updateSuppliserVendor = "update fy_supplier_vendor set cvenname=?,ctrade=?,cvenregcode=?,dorf=?,cqualitycond=?,cvenbank=?,cvenaccount=?,cmoneytype=?,cpurbillcode=?,couttype=?,cvenaddress=?,cvenpostcode=?, cvenperson=?, cvenphone=?,cvenfax=?,cvenemail=?,cveniaddress=?,ccuspaycond=?,ccontent=?,cycle=?,ccreateperson=?,dvendevdate=?, ts=?,cVenBankMemo=?,cvenfygl=? where cvencode=? and (dr='0' or dr is null) ";
	private static final String insertVendorInvcalss = "insert into fy_supplier_vendor_invclass (pk_veninv, pk_corp, pk_invclass, cvendorclass, ts, pk_vendor, dvendevdate, changeTrace,creater,bankaccountname,bankcode, bank,bankaccount,currency) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?)";
	private static final String SELECT_VENDOR_INVCLASS = "select t.pk_vendor, trim(t.pk_corp), t.pk_invclass, t.cvendorclass, t.pk_veninv,t.denddate from fy_supplier_vendor_invclass t, fy_supplier_vendor v where (t.dr='0' or t.dr is null) and v.pk_vendor = t.pk_vendor and v.cvencode = ? ";
	private static final String insertVendorInvcalssIfNotBlacklist = "insert into fy_supplier_vendor_invclass (pk_veninv, pk_corp, pk_invclass, cvendorclass, ts, pk_vendor, dvendevdate, changeTrace, creater,bankaccountname,bankcode, bank,bankaccount,currency) select ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,? from dual where not exists ( select * from fy_supplier_vendor_invclass where pk_corp=? and pk_invclass=? and pk_vendor=? and (dr='0' or dr is null) and ( cvendorclass = '3' or cvendorclass = '0'))";
	private static final String insertLog = "insert into fy_supplier_vendor_history(pk_venhis, pk_vendor, pk_corp, pk_invclass, changetype, changememo, changevouch, changecode, changer, ts, changedate,creater) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
	private static final String insertLogIfNotBlacklist = "insert into fy_supplier_vendor_history(pk_venhis, pk_vendor, pk_corp, pk_invclass, changetype, changememo, changevouch, changecode, changer, ts, changedate, creater) select ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? from dual where not exists (select * from fy_supplier_vendor_invclass where pk_corp=? and pk_invclass=? and pk_vendor=? and (dr='0' or dr is null) and cvendorclass = '3')";
	private static final String uapUserID = "0001AA10000000009KX7";
	private static final String ERPDELETESQL;
	private static final String ERPINSERTSQL;
	private ProviderImportFormBean providerImportFormBean;
	private List companyList;
	private List failRangeList;
	private List unchangingRangeList;
	private List successRangeList;
	private boolean writeToErpSuccess;

	public ProviderImportFormDao3() {
		writeToErpSuccess = false;
	}

	public List getFailRangeList() {
		return failRangeList;
	}

	public List getUnchangingRangeList() {
		return unchangingRangeList;
	}

	public List getSuccessRangeList() {
		return successRangeList;
	}

	public void setProviderImportFormBean(
			ProviderImportFormBean providerImportFormBean) {
		this.providerImportFormBean = providerImportFormBean;
	}

	public boolean save() {
		boolean success;
		Connection conn;
		PreparedStatement pst;
		PreparedStatement pst1;
		PreparedStatement pst2;
		ResultSet rs;
		success = false;
		conn = null;
		pst = null;
		pst1 = null;
		pst2 = null;
		rs = null;
		long changeTrace;
		try {
			conn = DBUtil.connect(FyConfig.getUAP_DB_CONFIG());

			changeTrace = UUIDLong.longUUID();
			conn.setAutoCommit(false);

			// if ("1".equals(providerImportFormBean.getProviderIsExist())) {
			// pst = conn
			// .prepareStatement("insert into fy_supplier_vendor (pk_vendor,cvencode,cvenname,ctrade,cvenregcode,dorf,cqualitycond,cvenbank,cvenaccount,cmoneytype,cpurbillcode,couttype,cvenaddress,cvenpostcode, cvenperson, cvenphone,cvenfax,cvenemail,cveniaddress,ccuspaycond,ccontent,cycle,ccreateperson,dvendevdate, ts, creater,cVenBankMemo,cvenfygl ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			// String pk_vendor = String.valueOf(UUIDLong.longUUID());
			// pst.setString(1, pk_vendor);
			// pst.setString(2, providerImportFormBean.getProviderCode());
			// pst.setString(3, providerImportFormBean.getProviderName());
			// pst.setString(4, providerImportFormBean.getCompanyType());
			// pst.setString(5, providerImportFormBean.getTaxRegister());
			// pst.setString(6, providerImportFormBean.getProperty());
			// pst.setString(7, providerImportFormBean.getQualitySystem());
			// pst.setString(8, providerImportFormBean.getCvenbank());
			// pst.setString(9, providerImportFormBean.getBankAccount());
			// pst.setString(10, providerImportFormBean.getCmoneytype());
			// pst.setString(11, providerImportFormBean.getCpurbillcode());
			// pst.setString(12, providerImportFormBean.getCouttype());
			// pst.setString(13, providerImportFormBean.getSupplyAddress());
			// pst.setString(14, providerImportFormBean.getPostCode());
			// pst.setString(15, providerImportFormBean.getLinkman());
			// pst.setString(16, providerImportFormBean.getTel());
			// pst.setString(17, providerImportFormBean.getFax());
			// pst.setString(18, providerImportFormBean.getEmail());
			// pst.setString(19, providerImportFormBean.getAddress());
			// pst.setString(20, providerImportFormBean.getCcuspaycond());
			// pst.setString(21, providerImportFormBean.getCcontent());
			// pst.setString(22, MyUtil.getLimitLengthString(
			// providerImportFormBean.getSupplyCycle(), 20, "\u2026"));
			// pst.setString(23, "0001AA10000000009KX7");
			// pst.setString(24, MyUtil.getTodayDateStr());
			// pst.setString(25, providerImportFormBean.getApplicationTime());
			// pst.setString(26, providerImportFormBean.getMemberCode());
			// pst.setString(27, providerImportFormBean.getcVenBankMemo());
			// pst.setString(28, providerImportFormBean.getCvenfygl());
			// pst.executeUpdate();
			// DBUtil.close(pst);
			// pst = conn
			// .prepareStatement("insert into fy_supplier_vendor_invclass (pk_veninv, pk_corp, pk_invclass, cvendorclass, ts, pk_vendor, dvendevdate, changeTrace,creater,bankaccountname,bankcode, bank,bankaccount,currency) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?)");
			// pst1 = conn
			// .prepareStatement("insert into fy_supplier_vendor_history(pk_venhis, pk_vendor, pk_corp, pk_invclass, changetype, changememo, changevouch, changecode, changer, ts, changedate,creater) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
			// int i = 0;
			// for (int size = companyList.size(); i < size; i++) {
			// String uapAccountID = (String) companyList.get(i);
			// List supplyRangeList = providerImportFormBean
			// .getSupplyRangeList();
			// int m = 0;
			// for (int mSize = supplyRangeList.size(); m < mSize; m++) {
			// String supplyRange = (String) supplyRangeList.get(m);
			// String pk_veninv = String.valueOf(UUIDLong.longUUID());
			// pst.setString(1, pk_veninv);
			// pst.setString(2, uapAccountID);
			// pst.setString(3, supplyRange);
			// pst.setString(4, "2");
			// pst.setString(5,
			// providerImportFormBean.getApplicationTime());
			// pst.setString(6, pk_vendor);
			// pst.setString(7, MyUtil.getTodayDateStr());
			// pst.setLong(8, changeTrace);
			// pst.setString(9, providerImportFormBean.getMemberCode());
			// pst.setString(10,
			// providerImportFormBean.getBankAccountName());
			// pst.setString(11, providerImportFormBean.getBankCode());
			// pst.setString(12,
			// providerImportFormBean.getcVenBankMemo());
			// pst.setString(13,
			// providerImportFormBean.getBankAccount());
			// pst.setString(14,
			// providerImportFormBean.getCmoneytype());
			// pst.addBatch();
			// writeLog(pst1, pk_vendor, uapAccountID, supplyRange,
			// "\u65B0\u589E");
			// }
			//
			// }
			//
			// pst.executeBatch();
			// pst1.executeBatch();
			// } else
			if ("0".equals("0")) {
				pst = conn
						.prepareStatement("update fy_supplier_vendor set cvenname=?,ctrade=?,cvenregcode=?,dorf=?,cqualitycond=?,cvenbank=?,cvenaccount=?,cmoneytype=?,cpurbillcode=?,couttype=?,cvenaddress=?,cvenpostcode=?, cvenperson=?, cvenphone=?,cvenfax=?,cvenemail=?,cveniaddress=?,ccuspaycond=?,ccontent=?,cycle=?,ccreateperson=?,dvendevdate=?, ts=?,cVenBankMemo=?,cvenfygl=? where cvencode=? and (dr='0' or dr is null) ");
				pst.setString(1, providerImportFormBean.getProviderName());
				pst.setString(2, providerImportFormBean.getCompanyType());
				pst.setString(3, providerImportFormBean.getTaxRegister());
				pst.setString(4, providerImportFormBean.getProperty());
				pst.setString(5, providerImportFormBean.getQualitySystem());
				pst.setString(6, providerImportFormBean.getCvenbank());
				pst.setString(7, providerImportFormBean.getBankAccount());
				pst.setString(8, providerImportFormBean.getCmoneytype());
				pst.setString(9, providerImportFormBean.getCpurbillcode());
				pst.setString(10, providerImportFormBean.getCouttype());
				pst.setString(11, providerImportFormBean.getSupplyAddress());
				pst.setString(12, providerImportFormBean.getPostCode());
				pst.setString(13, providerImportFormBean.getLinkman());
				pst.setString(14, providerImportFormBean.getTel());
				pst.setString(15, providerImportFormBean.getFax());
				pst.setString(16, providerImportFormBean.getEmail());
				pst.setString(17, providerImportFormBean.getAddress());
				pst.setString(18, providerImportFormBean.getCcuspaycond());
				pst.setString(19, providerImportFormBean.getCcontent());
				pst.setString(20, MyUtil.getLimitLengthString(
						providerImportFormBean.getSupplyCycle(), 20, "\u2026"));
				pst.setString(21, "0001AA10000000009KX7");
				pst.setString(22, MyUtil.getTodayDateStr());
				pst.setString(23, providerImportFormBean.getApplicationTime());
				pst.setString(24, providerImportFormBean.getcVenBankMemo());
				pst.setString(25, providerImportFormBean.getCvenfygl());
				pst.setString(26, providerImportFormBean.getProviderCode());
				pst.executeUpdate();
				DBUtil.close(pst);
				pst = conn
						.prepareStatement("select t.pk_vendor, trim(t.pk_corp), t.pk_invclass, t.cvendorclass, t.pk_veninv,t.denddate from fy_supplier_vendor_invclass t, fy_supplier_vendor v where (t.dr='0' or t.dr is null) and v.pk_vendor = t.pk_vendor and v.cvencode = ? ");
				pst.setString(1, providerImportFormBean.getProviderCode());
				rs = pst.executeQuery();
				String pk_vendor = null;
				List supplyTypeBeans = new ArrayList();
				while (rs.next()) {
					if (pk_vendor == null)
						pk_vendor = rs.getString(1);
					SupplyTypeBean bean = new SupplyTypeBean();
					bean.setPk_corp(rs.getString(2));
					bean.setPk_invclass(rs.getString(3));
					bean.setCvendorclass(rs.getString(4));
					bean.setPk_veninv(rs.getString(5));
					bean.setDenddate(rs.getString(6));
					supplyTypeBeans.add(bean);
					bean = null;
				}
				DBUtil.close(rs, pst);
				if (pk_vendor == null) {
					pst = conn
							.prepareStatement("select v.pk_vendor from fy_supplier_vendor v where v.cvencode=?");
					pst.setString(1, providerImportFormBean.getProviderCode());
					for (rs = pst.executeQuery(); rs.next();)
						pk_vendor = rs.getString(1);

				}
				DBUtil.close(rs, pst);
				pst = conn
						.prepareStatement("insert into fy_supplier_vendor_invclass (pk_veninv, pk_corp, pk_invclass, cvendorclass, ts, pk_vendor, dvendevdate, changeTrace, creater,bankaccountname,bankcode, bank,bankaccount,currency) select ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,? from dual where not exists ( select * from fy_supplier_vendor_invclass where pk_corp=? and pk_invclass=? and pk_vendor=? and (dr='0' or dr is null) and ( cvendorclass = '3' or cvendorclass = '0'))");
				pst1 = conn
						.prepareStatement("insert into fy_supplier_vendor_history(pk_venhis, pk_vendor, pk_corp, pk_invclass, changetype, changememo, changevouch, changecode, changer, ts, changedate, creater) select ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? from dual where not exists (select * from fy_supplier_vendor_invclass where pk_corp=? and pk_invclass=? and pk_vendor=? and (dr='0' or dr is null) and cvendorclass = '3')");
				pst2 = conn
						.prepareStatement("update fy_supplier_vendor_invclass set cvendorclass=?, changeTrace=?, denddate=?,bankaccountname=?,bankcode = ?, bank = ?,bankaccount = ?,currency = ? where pk_veninv=? and cvendorclass<>'3'");
				String operate = "0".equals(providerImportFormBean.getOption()) ? "\u6F5C\u5728"
						: "\u5408\u683C";
				String state = "0".equals(providerImportFormBean.getOption()) ? "2"
						: "1";
				int i = 0;
				for (int size = companyList.size(); i < size; i++) {
					String uapAccountID = (String) companyList.get(i);
					List supplyRangeList = providerImportFormBean
							.getSupplyRangeList();
					int m = 0;
					for (int mSize = supplyRangeList.size(); m < mSize; m++) {
						String supplyRange = (String) supplyRangeList.get(m);
						SupplyTypeBean supplyTypeBean = null;
						if ((supplyTypeBean = typeIsExist(uapAccountID,
								supplyRange, supplyTypeBeans)) == null) {
							if ("0".equals(providerImportFormBean.getOption())) {
								String pk_veninv = String.valueOf(UUIDLong
										.longUUID());
								pst.setString(1, pk_veninv);
								pst.setString(2, uapAccountID);
								pst.setString(3, supplyRange);
								pst.setString(4, state);
								pst.setString(5, providerImportFormBean
										.getApplicationTime());
								pst.setString(6, pk_vendor);
								pst.setString(7, MyUtil.getTodayDateStr());
								pst.setLong(8, changeTrace);
								pst.setString(9,
										providerImportFormBean.getMemberCode());
								pst.setString(10, providerImportFormBean
										.getBankAccountName());
								pst.setString(11,
										providerImportFormBean.getBankCode());
								pst.setString(12, providerImportFormBean
										.getcVenBankMemo());
								pst.setString(13,
										providerImportFormBean.getBankAccount());
								pst.setString(14,
										providerImportFormBean.getCmoneytype());
								pst.setString(15, uapAccountID);
								pst.setString(16, supplyRange);
								pst.setString(17, pk_vendor);
								pst.addBatch();
								writeLogIfPrividerExist(pst1, pk_vendor,
										uapAccountID, supplyRange, operate);
							}
						} else if (!"3"
								.equals(supplyTypeBean.getCvendorclass())
								&& (!state.equals(supplyTypeBean
										.getCvendorclass())
										&& !"1".equals(supplyTypeBean
												.getCvendorclass()) || supplyTypeBean
										.getDenddate() != null
										&& !"".equals(supplyTypeBean
												.getDenddate())
										&& !MyUtil.later(
												supplyTypeBean.getDenddate(),
												"00:00:00",
												MyUtil.getTodayDateStr(),
												"00:00:00"))) {
							pst2.setString(1, state);
							pst2.setLong(2, changeTrace);
							pst2.setString(3, "");
							pst2.setString(4,
									providerImportFormBean.getBankAccountName());
							pst2.setString(5,
									providerImportFormBean.getBankCode());
							pst2.setString(6,
									providerImportFormBean.getcVenBankMemo());
							pst2.setString(7,
									providerImportFormBean.getBankAccount());
							pst2.setString(8,
									providerImportFormBean.getCmoneytype());
							pst2.setString(9, supplyTypeBean.getPk_veninv());
							pst2.addBatch();
							writeLogIfPrividerExist(pst1, pk_vendor,
									uapAccountID, supplyRange, operate);
						} else {
							if (unchangingRangeList == null)
								unchangingRangeList = new ArrayList();
							unchangingRangeList.add(new RangeBean(uapAccountID,
									supplyRange));
						}
					}

				}

				pst.executeBatch();
				pst2.executeBatch();
				pst1.executeBatch();
			} else {

				log.error((new StringBuilder(
						"\u65E0\u6CD5\u786E\u8BA4\u4F9B\u5E94\u5546\u5BFC\u5165\u64CD\u4F5C,\u4F9B\u5E94\u5546\u5BFC\u5165\u8868\u5355\u636E\u7F16\u53F7\uFF1A"))
						.append(providerImportFormBean.getNumber()).toString());
				return false;

			}

			DBUtil.close(rs, pst);
			pst = conn
					.prepareStatement("update fy_supplier_vendor_invclass i set i.bankaccountname=?,i.bankcode = ?, i.bank = ?,i.bankaccount = ?,i.currency = ? where i.pk_vendor = ( select v.pk_vendor from fy_supplier_vendor v where v.cvencode = ? and nvl(v.dr,0) = 0) and i.pk_corp=?");
			int i = 0;
			for (int size = companyList.size(); i < size; i++) {
				String uapAccountID = (String) companyList.get(i);
				pst.setString(1, providerImportFormBean.getBankAccountName());
				pst.setString(2, providerImportFormBean.getBankCode());
				pst.setString(3, providerImportFormBean.getcVenBankMemo());
				pst.setString(4, providerImportFormBean.getBankAccount());
				pst.setString(5, providerImportFormBean.getCmoneytype());
				pst.setString(6, providerImportFormBean.getProviderCode());
				pst.setString(7, uapAccountID);

				log.info("供应商编码：" + providerImportFormBean.getProviderCode());

				pst.addBatch();
			}

			pst.executeBatch();
			DBUtil.close(pst);
			pst = conn.prepareStatement(ERPDELETESQL);
			pst.setString(1, providerImportFormBean.getProviderCode());
			pst.execute();
			pst = conn.prepareStatement(ERPINSERTSQL);
			pst.setString(1, providerImportFormBean.getProviderCode());
			pst.execute();
			conn.commit();
			DBUtil.setAutoCommit(conn, true);
			writeToErpSuccess = success = true;
			pst = conn
					.prepareStatement("select i.pk_corp, i.pk_invclass, c.unitname, si.cinvclasscode, v.cvencode, i.cvendorclass, v.cvenname from fy_supplier_vendor_invclass i left join bd_corp c on i.pk_corp = c.pk_corp left join fy_supplier_invclass si on si.pk_invclass = i.pk_invclass left join fy_supplier_vendor v on v.pk_vendor = i.pk_vendor where i.changeTrace= ?");
			pst.setLong(1, changeTrace);
			for (rs = pst.executeQuery(); rs.next(); successRangeList
					.add(new RangeBean(rs.getString(1), rs.getString(2), rs
							.getString(3), rs.getString(5), rs.getString(4), rs
							.getString(6), rs.getString(7))))
				if (successRangeList == null)
					successRangeList = new ArrayList();

			setFailRangeList();
		} catch (Exception e) {
			success = false;
			DBUtil.rollback(conn);
			e.printStackTrace();
			log.error(
					"\u4F9B\u5E94\u5546\u5BFC\u5165\u5BA1\u6279\u6570\u636E\u5BFC\u5165UPA\u5F02\u5E38",
					e);
		} finally {
			DBUtil.setAutoCommit(conn, true);
			DBUtil.close(pst2);
			DBUtil.close(pst1);
			DBUtil.close(rs, pst, conn);
		}

		return success;
	}

	private void setFailRangeList() {
		if (successRangeList == null
				|| successRangeList.size() < companyList.size()
						* providerImportFormBean.getSupplyRangeList().size()) {
			int i = 0;
			for (int size = companyList.size(); i < size; i++) {
				String uapAccountID = (String) companyList.get(i);
				List supplyRangeList = providerImportFormBean
						.getSupplyRangeList();
				int m = 0;
				for (int mSize = supplyRangeList.size(); m < mSize; m++) {
					String supplyRange = (String) supplyRangeList.get(m);
					boolean fail = true;
					if (successRangeList != null) {
						int o = 0;
						for (int sSize = successRangeList.size(); o < sSize; o++) {
							RangeBean bean = (RangeBean) successRangeList
									.get(o);
							if (uapAccountID.equals(bean.getPk_corp())
									&& supplyRange
											.equals(bean.getPk_invclass())) {
								fail = false;
								break;
							}
							bean = null;
						}

					}
					if (fail && unchangingRangeList != null) {
						int o = 0;
						for (int sSize = unchangingRangeList.size(); o < sSize; o++) {
							RangeBean bean = (RangeBean) unchangingRangeList
									.get(o);
							if (uapAccountID.equals(bean.getPk_corp())
									&& supplyRange
											.equals(bean.getPk_invclass())) {
								fail = false;
								break;
							}
							bean = null;
						}

					}
					if (fail) {
						if (failRangeList == null)
							failRangeList = new ArrayList();
						failRangeList.add(new RangeBean(uapAccountID,
								supplyRange));
					}
				}

			}

		}
	}

	private void writeLog(PreparedStatement pst1, String pk_vendor,
			String uapAccountID, String supplyRange, String operate)
			throws SQLException {
		pst1.setString(1, String.valueOf(UUIDLong.longUUID()));
		pst1.setString(2, pk_vendor);
		pst1.setString(3, uapAccountID);
		pst1.setString(4, supplyRange);
		pst1.setString(5, operate);
		pst1.setString(6, providerImportFormBean.getReason());
		pst1.setString(7, "OA\u4F9B\u5E94\u5546\u5BFC\u5165\u6279\u51C6\u8868");
		pst1.setString(8, providerImportFormBean.getNumber());
		pst1.setString(9, "0001AA10000000009KX7");
		pst1.setString(10, MyUtil.getNowStr());
		pst1.setString(11, MyUtil.getTodayDateStr());
		pst1.setString(12, providerImportFormBean.getMemberCode());
		pst1.addBatch();
	}

	private void writeLogIfPrividerExist(PreparedStatement pst1,
			String pk_vendor, String uapAccountID, String supplyRange,
			String operate) throws SQLException {
		pst1.setString(1, String.valueOf(UUIDLong.longUUID()));
		pst1.setString(2, pk_vendor);
		pst1.setString(3, uapAccountID);
		pst1.setString(4, supplyRange);
		pst1.setString(5, operate);
		pst1.setString(6, providerImportFormBean.getReason());
		pst1.setString(7, "OA\u4F9B\u5E94\u5546\u5BFC\u5165\u6279\u51C6\u8868");
		pst1.setString(8, providerImportFormBean.getNumber());
		pst1.setString(9, "0001AA10000000009KX7");
		pst1.setString(10, MyUtil.getNowStr());
		pst1.setString(11, MyUtil.getTodayDateStr());
		pst1.setString(12, providerImportFormBean.getMemberCode());
		pst1.setString(13, uapAccountID);
		pst1.setString(14, supplyRange);
		pst1.setString(15, pk_vendor);
		pst1.addBatch();
	}

	public boolean setUapAccountList() {
		companyList = providerImportFormBean.getCompanyIDList();
		return companyList != null && companyList.size() > 0;
	}

	private SupplyTypeBean typeIsExist(String pk_corp, String pk_invclass,
			List supplyTypeBeans) {
		if (supplyTypeBeans != null) {
			int i = 0;
			for (int size = supplyTypeBeans.size(); i < size; i++)
				if (supplyTypeBeans.get(i) != null
						&& pk_corp.equals(((SupplyTypeBean) supplyTypeBeans
								.get(i)).getPk_corp())
						&& pk_invclass.equals(((SupplyTypeBean) supplyTypeBeans
								.get(i)).getPk_invclass()))
					return (SupplyTypeBean) supplyTypeBeans.get(i);

		}
		return null;
	}

	public boolean isWriteToErpSuccess() {
		return writeToErpSuccess;
	}

	static {
		ERPDELETESQL = (new StringBuilder(
				"delete from apps.FYG_PO_UAP_VENDORS@"))
				.append(FyConfig.getERP_DB_CONFIG().getDblink())
				.append(" i where i.VENDORS_NUM = ?  and i.ZT<>'\u5BA2\u6237' ")
				.toString();
		ERPINSERTSQL = (new StringBuilder(
				"insert into apps.FYG_PO_UAP_VENDORS@"))
				.append(FyConfig.getERP_DB_CONFIG().getDblink())
				.append("(VENDORS_NUM, VENDORS_NAME, SYB, UAPLB, ZT, disable_date,flag) select v.cvencode,v.cvenname, c.unitname, i.cinvclasscode,         decode(vi.cvendorclass,'1','\u5408\u683C','2','\u6F5C\u5728','3','\u9ED1\u540D\u5355',vi.cvendorclass,vi.cvendorclass),         to_date(vi.denddate,'YYYY-MM-DD'),'Y'    from fy_supplier_vendor_invclass vi    left join fy_supplier_vendor v on vi.pk_vendor = v.pk_vendor    left join bd_corp c on vi.pk_corp = c.pk_corp    left join fy_supplier_invclass i on vi.pk_invclass = i.pk_invclass   where v.cvencode = ? and (vi.dr is null or vi.dr = 0) and  vi.cvendorclass <>'3' and (vi.denddate is null or to_date(vi.denddate,'yyyy-mm-dd') > to_date( to_char(sysdate, 'yyyy-mm-dd'), 'yyyy-mm-dd' ))")
				.toString();
	}
}

class SupplyTypeBean {
	private String pk_corp;
	private String pk_invclass;
	private String cvendorclass;
	private String pk_veninv;
	private String denddate;

	public String getDenddate() {
		return denddate;
	}

	public void setDenddate(String denddate) {
		this.denddate = denddate;
	}

	public String getPk_veninv() {
		return pk_veninv;
	}

	public void setPk_veninv(String pk_veninv) {
		this.pk_veninv = pk_veninv;
	}

	public String getPk_corp() {
		return pk_corp;
	}

	public void setPk_corp(String pk_corp) {
		this.pk_corp = pk_corp;
	}

	public String getPk_invclass() {
		return pk_invclass;
	}

	public void setPk_invclass(String pk_invclass) {
		this.pk_invclass = pk_invclass;
	}

	public void setCvendorclass(String cvendorclass) {
		this.cvendorclass = cvendorclass;
	}

	public String getCvendorclass() {
		return cvendorclass;
	}

}
